package net.jalbum.filters;

public class MultipleResizableBoxPanel extends MultipleResizableObjectPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = -4545036738030752700L;
	protected MultipleResizableBoxControl multipleResizableBoxControl;
	protected ResizableBox resizableBox;
	protected double initalX1 = 0;
	protected double initalY1 = 0;
	protected double initalX2 = 0.5;
	protected double initalY2 = 0.5;

	public MultipleResizableBoxPanel() {
		this.name = "MultipleResizableBoxPanel";
		this.author = "David Fichtmueller";
		this.version = "1.0";
		this.description = "This is just for inheriting for other filters. This is not applieable.";
		this.prescale = true;
		this.postscale = false;

		this.resizableBox = new ResizableBox();
		this.multipleResizableBoxControl = new MultipleResizableBoxControl(this);

		this.namePrefix = "Resizable Box ";
		this.resizableBox.setName(this.namePrefix + (this.counter - 1));
		this.resizableBox.setParentPanel(this);
		this.resizableBox.setX1(this.initalX1);
		this.resizableBox.setY1(this.initalY1);
		this.resizableBox.setX2(this.initalX2);
		this.resizableBox.setY2(this.initalY2);

		this.resizableObject = this.resizableBox;
		this.hoveredOverObject = this.resizableObject;
	}

	@Override
	public void addObject() {
		if (!this.resizableObject.isInitial()) {
			this.resizableObject.setState(ResizableObject.NOTHING);

			this.resizableBox = new ResizableBox(this.width, this.height);
			this.resizableBox.setName(this.namePrefix + this.counter);
			this.resizableBox.setParentPanel(this);
			this.resizableBox.setX1(this.initalX1);
			this.resizableBox.setY1(this.initalY1);
			this.resizableBox.setX2(this.initalX2);
			this.resizableBox.setY2(this.initalY2);
			// new circle is added on top of the others
			this.objectVector.add(0, this.resizableBox);
			this.resizableObject = this.resizableBox;
			this.counter++;
		}
	}

	public void setMultipleResizableBoxControl(final MultipleResizableBoxControl multipleResizableBoxControl) {
		this.multipleResizableBoxControl = multipleResizableBoxControl;

	}

	public void updateObject(final int x, final int y, final int width, final int height) {
		// this method is called by the controller to pass new settings to the box
		((ResizableBox) (this.resizableObject)).update(x, y, width, height);
		this.resizableObject.setInitial(false);
		this.renderPreview();
	}

	public ResizableBox getResizableBox() {
		return (ResizableBox) (this.resizableObject);
	}

	public double getInitalX1() {
		return this.initalX1;
	}

	public void setInitalX1(final double initalX1) {
		this.initalX1 = initalX1;
	}

	public double getInitalY1() {
		return this.initalY1;
	}

	public void setInitalY1(final double initalY1) {
		this.initalY1 = initalY1;
	}

	public double getInitalX2() {
		return this.initalX2;
	}

	public void setInitalX2(final double initalX2) {
		this.initalX2 = initalX2;
	}

	public double getInitalY2() {
		return this.initalY2;
	}

	public void setInitalY2(final int initalY2) {
		this.initalY2 = initalY2;
	}

	public void setResizableBox(final ResizableBox resizableBox) {
		this.resizableBox = resizableBox;
	}
}
